<script setup lang="ts">
import CourseCard from "@/components/common/CourseCard.vue";
import {getMostNew} from "@/api/home";
import {onBeforeMount, Ref, ref} from "vue";
import {AxiosResponse} from "axios";
const mostNewData:Ref<any[],any[]> = ref([])
const getMostNewData = async()=>{
  const res:AxiosResponse<any, any> = await getMostNew({pageNum:2,pageSize:6})
  console.log(res)
  mostNewData.value = res.data.pageInfo.list
}
onBeforeMount(()=>{
  getMostNewData().then(() => {})
})
</script>

<template>
  <div class="course">
    <div class="course-main">
      <div class="course-top">
        <div class="hot">
          <div class="hot-left">HOT</div>
          <div class="hot-right"></div>
        </div>
        <div class="title"> <p>推荐好课</p></div>
      </div>
      <div class="course-bottom">
        <img class="picture" src="https://oss.xuexiluxian.cn/xiaoluxian-vcr/653367ac8b974c65bd3cbef4f996b5b4.png" alt="推荐好课">
        <ul>
          <li v-for="item in mostNewData" :key="item.id">
            <CourseCard
                :count="item.clicks"
                :dengji="item.courseLevel"
                :price = "item.discountPrice"
                :img-url="item.courseCover"
                :title="item.courseName"
            />
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>

<style scoped>
.course {
  margin-top: 40px;
  width: 100%;
  .course-main{
    width: 1000px;
    margin: 0 auto;
    .course-top{
      display: flex;
      justify-content: start;
      height: 38px;
      .hot{
        width: 60px;
        display: flex;
        .hot-left{
          width: 100%;
          height: 38px;
          border-radius:  7px 0 7px 7px;
          background:linear-gradient(90deg, #ff727f 0%, #fc685c 100%) ;
          display: flex;
          justify-content: center;
          align-items: center;
        }
        .hot-right{
          width: 0;
          height: 0;
          border: 6px solid #fc685c;
          border-right-color: transparent;
          border-bottom-color: transparent;
        }
      }
      .title{
        width: 106px;
        display: flex;
        position: relative;
        text-align: center;
        p{
          width: 106px;
          font-size: 1.5em;
          font-weight: 600;
          z-index: 3;
        }
        &:after{
          content: '';
          display: inline-block;
          width: 106px;
          height: 13px ;
          background: linear-gradient(90deg, #fbf84f 0%, #fea935 100%);
          position:absolute ;
          bottom: 2px;
          border-radius: 5px;
        }
      }
    }
    .course-bottom{
      display: flex;
      justify-content: space-between;
      .picture{
        width: 230px;
        margin-top: 20px;
      }
      ul{
        display: flex;
        width: 740px;
        justify-content: start;
        flex-wrap: wrap;
        li{
          margin-top: 20px;
          margin-right: 24px;
          &:nth-child(3n){
            margin-right: 0;
          }
        }
      }
    }
  }
}
</style>